package com.chuangjiangx.member.basic.ddd.domain.model.calc;

import java.math.BigDecimal;

/**

 */
public class AmountScoreGrandTotalCalc {


    public Long plusScoreCalc(BigDecimal amount,BigDecimal ruleAmount,Long ruleScore) {

        // 计算公式（支付金额 / 规则金额）* 规则积分 = 用户可获得积分
        int cardinal = amount.divide(ruleAmount,8,BigDecimal.ROUND_DOWN).intValue();
        return cardinal*ruleScore;
    }


    public Long subtractScoreCalc(BigDecimal refundAmount,BigDecimal amountHis, Long scoreHis) {

        return new BigDecimal(Long.toString(scoreHis))
                .divide(amountHis, 8, BigDecimal.ROUND_DOWN)
                .multiply(refundAmount)
                .setScale(0, BigDecimal.ROUND_DOWN)
                .longValue();


    }
}